package Grasnador.Grasnador0.DAO;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;

import Grasnador.Grasnador0.DTO.Grasnado;
import Grasnador.Grasnador0.DTO.User;
import Grasnador.Grasnador0.Generic.GenericDAO;
import Grasnador.Grasnador0.util.HibernateUtil;


public class GrasnadoDAO extends GenericDAO {

	public GrasnadoDAO() {
		super(Grasnado.class);
	}

	@Override
	public List getByName(String name) {
		try {
            List<User> lista = new ArrayList<User>();
            Session session = HibernateUtil.getSessionFactory().openSession();
            session.beginTransaction();
            lista = session.createQuery("FROM grasnado as g WHERE LOWER (g.content) LIKE  '%" + name.toLowerCase() + "%'").list();
            session.getTransaction().commit();
            return lista;
        } catch (IndexOutOfBoundsException e) {
            return null;
        }
	}

}
